package com.itheima.service.impl;

import com.itheima.domain.vo.JobOption;
import com.itheima.domain.vo.StudentOption;
import com.itheima.mapper.EmpMapper;
import com.itheima.mapper.StudentMapper;
import com.itheima.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author: Sch
 * @Date: 2025/07/14 16:24
 * @Description:
 */
@Service
public class ReportServiceImpl implements ReportService {
    @Autowired
    private EmpMapper empMapper;
    @Autowired
    private StudentMapper studentMapper;

    @Override
    public JobOption getEmpJobData() {
        List<Map<String, Object>> list = empMapper.countEmpJobData();
        List<String>jobList = list.stream().map(dataMap -> (String) dataMap.get("pos")).collect(Collectors.toList());
        List<Long>dataList = list.stream().map(dataMap ->(Long) dataMap.get("total")).collect(Collectors.toList());
        return new JobOption(jobList,dataList);
    }


    @Override
    public List<Map> getEmpGenderData() {
        return empMapper.countEmpGenderData();
    }

    @Override
    public List<Map> getStudentDegreeData() {
        return studentMapper.countStudentDegreeData();
    }

    @Override
    public StudentOption getStudentCountData() {
        List<Map<String, Object>> list = studentMapper.countStudentCountData();
        List<String> clazzList = list.stream().map(dataMap -> (String) dataMap.get("pos")).collect(Collectors.toList());
        List<Long> dataList = list.stream().map(dataMap -> (Long) dataMap.get("total")).collect(Collectors.toList());
        return new StudentOption(clazzList,dataList);
    }
}
